<!DOCTYPE html>
            
<HTML>
<HEAD>
<meta name="booktitle" content="Developing Applications With Objective Caml" >
 <meta charset="ISO-8859-1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<META name="GENERATOR" content="hevea 1.05-7 of 2000-02-24">
<META NAME="Author" CONTENT="Christian.Queinnec@lip6.fr">
<LINK rel=stylesheet type="text/css" href="videoc-ocda.css">
<script language="JavaScript" src="videoc.js"><!--
//--></script>
<TITLE>
 Introduction
</TITLE>
</HEAD>
<BODY class="regularBody">
<A HREF="book-ora171.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora174.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2> Introduction</H2>
<A NAME="@concepts346"></A>Concurrency is the word used to describe causal independence 
between a number of actions, such as the execution of a number of
instructions ``at the same time''. This is also the definition which we give
of the term ``parallel'' in the introduction of this fourth part. The
processes of the <TT>Unix</TT> library presented in the preceding
chapter could be considered as concurrent to the extent that the
<TT>Unix</TT> system provides the appearance of their simultaneous execution
on a uniprocessor machine. But the notion of process and concurrency
does not apply only to those obtained by the <TT>fork</TT> system
call.<BR>
<BR>
The Objective CAML language possesses a library for lightweight processes
(threads.) The principle difference between a thread and a process
is in the sharing or non-sharing of memory between the different
child processes of the same program. Only the context of execution
differs between two threads: the code and memory sections of the data
are shared. Threads do not improve the execution time of an
application. Their principal attraction is to make it possible to
express the programming of concurrent algorithms within a language.<BR>
<BR>
The nature of the chosen language, imperative or functional, affects
the model of concurrency. For an imperative program, as every thread
can modify the communal/shared memory, we are in a shared memory
model. Communication between processes can be achieved by values
written and read in this memory. For a purely functional program,
that is to say, without side effects, even though the memory is
shared, the calculations which each process executes do not act on this
shared memory. In this case, the model used is that of separate
memory and interaction between processes must be achieved by
communication of values though channels.<BR>
<BR>
The Objective CAML language implements both models in its thread library.
The <TT>Thread</TT> module makes it possible to start new processes
corresponding to a function call with its argument. Modules
<TT>Mutex</TT> and <TT>Condition</TT> provide the synchronization
tools for mutual exclusion and waiting on a condition. The
<TT>Event</TT> model implements a means of communication of language
values by events. These values can themselves be functional, thus
making it possible to exchange calculations to be carried out between
threads. As always in Objective CAML it is possible to mix the two models.<BR>
<BR>
This library is portable to the different systems where OCAML runs.
Unlike the <TT>Unix</TT> module, the <TT>Thread</TT> library
facilitates the use of processes on machines that are not running
Unix.<BR>
<BR>
<HR>
<A HREF="book-ora171.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora174.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
